home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / love4th.zip / DEMO-MU.DEM < prev    next >
Text File  |  1991-10-01  |  1KB  |  43 lines

  1. |O|Dalso ourdemo  : junk ;    last demo-hs !|E
  2. |B|" Here are the current dictionary pointers:"
  3. |Dmem. save-mem|E
  4. |" Notice how they change after the following definition."|A
  5. |K: Hello
  6.   ." Greetings from the makers of LOVE FORTH" ;
  7. |O|B|Dmem. dif. |E
  8.  
  9. |" The majority of this definition was added to the data segment."
  10. |" This is because text strings are always added to the data segment."
  11. |F
  12. |Dpage mem. save-mem create D2* |E
  13. |" Notice how a code definition is added to the code segment."|A
  14.  
  15. |D\ |Ecode D2* ;( d -- d )
  16. |D\|E     pop ax
  17. |D\|E     pop bx
  18. |D\|E     shl bx, 1
  19. |D\|E     rcl ax, 1
  20. |D\|E     push bx
  21. |D\|E     push ax
  22. |D\|E     next
  23. |K|D\ |Ec;|B
  24. |O|D|B10 dpcode +!    -2 dp +!  mem. dif. |E
  25. |" The two bytes added to the threads is the CFA of the new word."
  26. |F
  27. |Dpage mem. save-mem |E
  28. |" The next definition is entirely in high level Forth."
  29. |" Notice how the long name affects only the head segment."|A
  30.  
  31. : ADD-SIX-TO-THE-TOP-OF-THE-STACK ( n -- n )|K
  32.   6 + ;
  33. |O|D|Bmem. dif. save-mem|E|A
  34. : 6+ ( n -- n )|K
  35.   6 + ;
  36. |O|D|Bmem. dif. |E
  37. |" The eight bytes in the thread segment are the body of the definition."
  38. |" In this case the code and data segments do not change."|A
  39.  
  40. 46 ADD-SIX-TO-THE-TOP-OF-THE-STACK .|K
  41. 46 6+ .
  42. |A|F|Bourdemo to-menu
  43.